package src.leetcode.greedy.medium_0055;

public class canJump {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.canJump(new int[]{2, 3, 1, 1, 4}));
    }
}

class Solution {
    public boolean canJump(int[] nums) {
        if(nums.length < 2) return true;

        int furthest = nums[0];

        for(int i = 1; i <= furthest; i++){
            if(furthest >= nums.length - 1) return true;
            furthest = Math.max(furthest, i + nums[i]);
        }

        return false;
    }
}